<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8">
	<title>通知公告</title>
	<script th:src="@{/layui/layui.js}" type="text/javascript"></script>
	<script th:src="@{/js/notice.js}" type="text/javascript"></script>
	<link th:href="@{/layui/css/layui.css}" rel="stylesheet" />
	<link th:href="@{/css/notice.css}" rel="stylesheet" />
	</head>
<body>
	<div class="layui-panel" style="padding: 8px;">
	    <fieldset class="layui-elem-field layui-border-blue">
	        <legend>通知公告</legend>
	        <form class="layui-form layui-form-pane" style="margin: 20px;">
	            <div class="layui-form-item">
	                <div class="layui-inline">
	                    <label class="layui-form-label">公告名称</label>
	                    <div class="layui-input-inline">
	                        <input class="layui-input" type="text" name="name" autocomplete="off" />
	                    </div>
	                </div>
	                <div class="layui-inline">
	                    <div class="layui-input-inline">
	                    	
	                        <a class="layui-btn layui-btn-primary" id="searchBtn" lay-submit="" lay-filter="searchBtn">
	                            <i class="layui-icon layui-icon-search"></i>
	                           		 搜索
	                        </a>
   
	                    </div>
	                </div>
	            
	            </div>
	        </form>
	    </fieldset>
	    <div>
	        <table id="noticeTable" lay-filter="noticeTable"></table>
	    </div>
	</div>
	<!---->
	<script id="tool" type="text/html">
<!--		<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="look">详情</a>-->
		<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="edit">编辑</a>
		<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
	</script>
	<!---->
	<script id="tableBar" type="text/html">
	    <a class="layui-btn layui-btn-normal layui-btn-md" id="add" lay-event="add">
	        <i class="layui-icon layui-icon-add-1"></i>
	        新增
	    </a>
<!--	    <a class="layui-btn layui-btn-danger layui-btn-md" lay-event="delete">-->
<!--	        <i class="layui-icon layui-icon-delete"></i>-->
<!--	        删除-->
<!--	    </a>-->
	</script>
	<!---->
	
	
<script>
	var $,active;
		layui.use(['notice','table','form','laydate','layer','jquery','dropdown'],function(){
			
        	var table = layui.table,
        	form = layui.form,
        	layer = layui.layer,
            laydate = layui.laydate,
            dropdown = layui.dropdown,
            notice = layui.notice;
			$ = layui.jquery;
            	
			laydate.render({
				elem:'#endDate'
			})
			laydate.render({
				elem:'#endDate'
			})
			
			// 初始化配置，同一样式只需要配置一次，非必须初始化，有默认配置
			notice.options = {
            closeButton:true,//显示关闭按钮
            debug:false,//启用debug
            positionClass:"toast-top-right",//弹出的位置,
            showDuration:"3000",//显示的时间
            hideDuration:"1000",//消失的时间
            timeOut:"5000",//停留的时间
            extendedTimeOut:"1000",//控制时间
            showEasing:"swing",//显示时的动画缓冲方式
            hideEasing:"linear",//消失时的动画缓冲方式
            iconClass: 'toast-info', // 自定义图标，有内置，如不需要则传空 支持layui内置图标/自定义iconfont类名
            onclick: null, // 点击关闭回调
        	};
				
			
	        // notice.warning("成功");//黄色
	        // notice.info("提示信息：毛都没有...");//蓝色
	        // notice.error("大佬，我咋知道怎么肥四！");//红色
	        // notice.success("大佬，我咋知道怎么肥四！");//绿色
			
			 var notice01;
			 var options = {
                closeButton:true,//显示关闭按钮
                debug:false,//启用debug
                positionClass:"toast-top-center",//弹出的位置,
                showDuration:"300",//显示的时间
                hideDuration:"1000",//消失的时间
                timeOut:"0",//停留的时间,0则不自动关闭
                extendedTimeOut:"1000",//控制时间
                showEasing:"swing",//显示时的动画缓冲方式
                hideEasing:"linear",//消失时的动画缓冲方式
                iconClass: 'layui-icon layui-icon-praise', // 自定义图标，有内置，如不需要则传空 支持layui内置图标/自定义iconfont类名,需要完整加上 layui-icon/icon iconfont
                onclick: null, // 点击关闭回调
                }
			 
        	$("#searchBtn").click(function () {

            notice01 = notice.success("大佬，我咋知道怎么肥四！","我是标题",options);

        	});


        	
        	 window.setTimeout(function () {
       
        }, 3500);

			
			//加载动态表格
			table.render({
				
				elem:'#noticeTable',
				height:'full-160',
				page:true,
				toolbar:'#tableBar',
				url:'/notice/nc/find',
				cols:[
						[
					{type:'numbers',fixed:'left'},
					{type:'checkbox',fixed:'left'},
					//{field:'id',title:'id',width:100,align: 'center'},
					{field:'title',title:'公告标题',width:150,align: 'center'},
					{field:'content',title:'通知内容',width:200,align: 'center'},
					{field:'adminId',title:'通知对象',width:180,align: 'center'},
					{field:'addTime',title:'创建时间',width:300,align: 'center'},
					{field:'updateTime',title:'更新时间',width:300,align: 'center'},
					{fixed:'right',title:'操作',width:160,align:'center',toolbar:'#tool'},
				]
				]
			})

			active = {
				addOrUpdate:function (btn,title,content) {
					var b = false;
					top.layer.open({
						title:title,
						type:2,
						content:content,
						area:['900px','750px'],
						btn:[btn,'取消关闭'],
						btn1:function (i,o) {
							b = true;
							o.find('iframe')[0].contentWindow.btnSubmit();
							if (b) notice.success("成功");
						},
						end:function (i,o) {
							if (b) layui.table.reload('noticeTable');
						}
					})
				},
				deleteConfirm:function (ids) {
					layer.confirm('确定删除该记录？',function (index) {
						if (index>0){
							$.ajax({
								type:'post',
								url:'/notice/nc/delete',
								data:{
									id:ids
								},
								dataType:'json',
								success:function (result) {
									layer.msg(result.msg);
									if (result.is){
										layui.table.reload('noticeTable');
										notice.success("删除成功");
									}
								}
							})
						}
					});

				}
			}

			//add
			table.on('toolbar(noticeTable)',function (obj) {
				var event = obj.event;
				if ("add"==event){
					active.addOrUpdate('确认保存','新增公告','/page/system/noticeAdd');
				}
			})
			//edit
			table.on('tool(noticeTable)',function (obj) {
				var event = obj.event;
				if ("edit"==event){
					active.addOrUpdate('更新保存','修改公告','/page/system/noticeEdit/'+obj.data.id);
				} else if ('delete' == event){
					var ids = obj.data.id;
					active.deleteConfirm(ids);
				}
			})
			
		});
	
</script>
	
	
	</body>
</html>
